
#include "Ped.h"
#include "../ScriptApi.h"

namespace GTA
{

#pragma region constructor
	// -- constructor -- 
	Ped::Ped()
	{
	}

	Ped::Ped(Scripting::Ped ped)
	{
		Base = ped;
	}
	
	Ped::Ped(u32 handle)
	{
		Handle = handle;
	}
	// -- /constructor --
#pragma endregion constructor

#pragma region base
	// -- base -- 
	Scripting::Ped Ped::Base::get()
	{
		Scripting::Ped ped;
		ped.Handle = Handle;
		return ped;
	}
	void Ped::Base::set(Scripting::Ped ped)
	{
		Handle = ped.Handle;
	}

	bool Ped::Exists()
	{
		if (Handle == 0) return false;
		return Scripting::DoesCharExist(this->Base);
	}
	bool Ped::Exists(Ped^ ped)
	{ // STATIC!
		if (ped == nullptr) return false;
		if (ped->Handle == 0) return false;
		return ped->Exists();
	}
	// -- /base -- 
#pragma endregion Base, Handle, Exists()

#pragma region properties
	GTA::Vector3^ Ped::Coordinates::get()
	{
		float x,y,z;
		pin_ptr<float> pX = &x;
		pin_ptr<float> pY = &y;
		pin_ptr<float> pZ = &z;
		Scripting::GetCharCoordinates(Base,pX,pY,pZ);
		GTA::Vector3^ pos = gcnew GTA::Vector3(x,y,z);
		return pos;
	}
	void Ped::Coordinates::set(GTA::Vector3^ pos)
	{
		Scripting::SetCharCoordinates(Base,pos->X,pos->Y,pos->Z);
	}

	f32 Ped::Heading::get()
	{
		float heading;
		pin_ptr<float> pheading = &heading;
		Scripting::GetCharHeading(Base,pheading);
		return heading;
	}
	void Ped::Heading::set(f32 heading)
	{
		Scripting::SetCharHeading(Base,heading);
	}

	u32 Ped::Health::get()
	{
		u32 health;
		pin_ptr<u32> phealth = &health;
		Scripting::GetCharHealth(Base,phealth);
		return health;
	}
	void Ped::Health::set(u32 health)
	{
		Scripting::SetCharHealth(Base,health);
	}

	GTA::eModel Ped::Model::get()
	{
		GTA::eModel model;
		pin_ptr<GTA::eModel> pmodel = &model;
		Scripting::GetCharModel(Base,(Scripting::eModel*)pmodel);
		return model;
	}

#pragma endregion Coordinates, Heading, Health, Model

#pragma region methods
	GTA::Vehicle^ Ped::GetVehiclePedIsDriving()
	{
		Scripting::Vehicle sVeh;
		pin_ptr<Scripting::Vehicle> pVeh = &sVeh;
		Scripting::GetCarCharIsUsing(Base,pVeh);
		return gcnew GTA::Vehicle(sVeh);
	}
#pragma endregion GetVehiclePedIsDriving()

};